home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / Printer / src / HP / transfer.c < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.2 KB  |  77 lines

  1. /*
  2.     Transfer routine for HP_LaserJet driver.
  3.     David Berezowski - October/87.
  4.  
  5.   Copyright (c) 1988 Commodore-Amiga, Inc.
  6.  
  7.   Executables based on this information may be used in software
  8.   for Commodore Amiga computers.  All other rights reserved.
  9.  
  10.   This information is provided "as is"; no warranties are made.
  11.   All use is at your own risk, and no liability or responsibility is assumed.
  12. */
  13.  
  14.  
  15. #include <exec/types.h>
  16. #include "../printer/prtgfx.h"
  17.  
  18. Transfer(PInfo, y, ptr)
  19. struct PrtInfo *PInfo;
  20. UWORD y;    /* row # */
  21. UBYTE *ptr;    /* ptr to buffer */
  22. {
  23.     static UBYTE bit_table[] = {128, 64, 32, 16, 8, 4, 2, 1};
  24.     UBYTE *dmatrix, Black, dvalue, threshold;
  25.     union colorEntry *ColorInt;
  26.     UWORD x, width, sx, *sxptr, bit;
  27.  
  28.     /* pre-compute */
  29.     /* printer non-specific, MUST DO FOR EVERY PRINTER */
  30.     x = PInfo->pi_xpos; /* get starting x position */
  31.     ColorInt = PInfo->pi_ColorInt; /* get ptr to color intensities */
  32.     sxptr = PInfo->pi_ScaleX;
  33.     width = PInfo->pi_width; /* get # of source pixels */
  34.  
  35.     /* pre-compute threshold; are we thresholding? */
  36.     if (threshold = PInfo->pi_threshold) { /* thresholding */
  37.         dvalue = threshold ^ 15; /* yes, so pre-compute dither value */
  38.         do { /* for all source pixels */
  39.             /* pre-compute intensity value for Black */
  40.             Black = ColorInt->colorByte[PCMBLACK];
  41.             ColorInt++; /* bump ptr for next time */
  42.  
  43.             sx = *sxptr++;
  44.  
  45.             /* dither and render pixel */
  46.             do { /* use this pixel 'sx' times */
  47.                 /* if we should render Black */
  48.                 if (Black > dvalue) {
  49.                     /* set bit */
  50.                     *(ptr + (x >> 3)) |= bit_table[x & 7];
  51.                 }
  52.                 ++x; /* done 1 more printer pixel */
  53.             } while (--sx);
  54.         } while (--width);
  55.     }
  56.     else { /* not thresholding, pre-compute ptr to dither matrix */
  57.         dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  58.         do { /* for all source pixels */
  59.             /* pre-compute intensity value for Black */
  60.             Black = ColorInt->colorByte[PCMBLACK];
  61.             ColorInt++; /* bump ptr for next time */
  62.  
  63.             sx = *sxptr++;
  64.  
  65.             /* dither and render pixel */
  66.             do { /* use this pixel 'sx' times */
  67.                 /* if we should render Black */
  68.                 if (Black > dmatrix[x & 3]) {
  69.                     /* set bit */
  70.                     *(ptr + (x >> 3)) |= bit_table[x & 7];
  71.                 }
  72.                 ++x; /* done 1 more printer pixel */
  73.             } while (--sx);
  74.         } while (--width);
  75.     }
  76. }
  77.